import Vue from "vue";
import VueRouter from "vue-router";
// import是静态加载模块，编译就加载
import Home from "../views/Home.vue";

// Vue加载VueRouter的插件
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/about",
    name: "About",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
    // import异步动态加载模块，执行才加载，这个import不是一开始就加载好了的，
    // 是要等到访问了我这个路径才开始加载的
      import(/* webpackChunkName: "about" */ "../views/About.vue"),
  },
];

const router = new VueRouter({
  routes,
});

export default router;
